package com.my.test.thread.atomic;

import java.util.concurrent.atomic.AtomicInteger;

public class TestAtomicInteger {

    private static AtomicInteger ai = new AtomicInteger(1);

    public static void main(String[] args) {

        System.out.println(ai.getAndIncrement());  // 1  返回的是自增长之前的值
        System.out.println(ai.incrementAndGet());  // 3
        System.out.println(ai.get());// 3

        System.out.println("--------------");
        int i = 1;
        System.out.println(i++); // 1
        System.out.println(++i); // 3
        System.out.println(i);   // 3
    }
}
